//**********************************************************
//    File Name: Tasks.cs
//    Author: Team Motif
//    Date Created : 04/13/2007
//    Current Owner: Team Motif 
//                                                                            
//    Purpose: 
//    This class provides the functions needed to access the tasks that a homecare
//    worker can perform or the tasks that a client requires.
//
//	  Copyright 2007
//**********************************************************

using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace Library
{
    public class Task
    {
        /// <summary>
        /// -------------------------------------------------------------------------------
        /// Constructor for Task a do-nothing constructor
        /// -------------------------------------------------------------------------------
        /// </summary>
        public Task()
        {

        }

        /// <summary>
        /// -------------------------------------------------------------------------------
        /// Constructor for Task
        /// -------------------------------------------------------------------------------
        /// </summary>
        /// <param name="taskIdentifier"></param>
        /// <param name="name"></param>
        /// <param name="description"></param>
        public Task(int taskIdentifier, string name, string description)
        {
            taskID = taskIdentifier;
            taskName = name;
            taskDescription = description;
        }

        /// <summary>
        /// -------------------------------------------------------------------------------
        /// Returns the taskID
        /// -------------------------------------------------------------------------------
        /// </summary>
        /// <returns></returns>
        public int GetTaskID()
        {
            return taskID;
        }
        
        /// <summary>
        /// -------------------------------------------------------------------------------
        /// Returns the taskName
        /// -------------------------------------------------------------------------------
        /// </summary>
        /// <returns></returns>
        public String GetTaskName()
        {
            return taskName;
        }

        /// <summary>
        /// -------------------------------------------------------------------------------
        /// This function accepts an array of task names and returns an array of Task objects
        /// -------------------------------------------------------------------------------
        /// </summary>
        /// <param name="taskNameList"></param>
        /// <returns></returns>
        public static ArrayList GetTasksFromName(ArrayList taskNameList)
        {
            ArrayList taskObjectsList = new ArrayList();
            System.Object lockThis = new System.Object();
            lock (lockThis)
            {
                for (int i = 0; i < taskNameList.Count; i++)
                {
                    Task newTask = new Task();
                    newTask = DBUtil.ReadTaskByName(taskNameList[i] as String);
                    taskObjectsList.Add(newTask);
                }
            }
            return taskObjectsList;
        }

        /// <summary>
        /// -------------------------------------------------------------------------------
        /// Returns the taskIDs, names for all Tasks for a particular client
        /// -------------------------------------------------------------------------------
        /// </summary>
        /// <param name="tmpClientID"></param>
        /// <returns></returns>
        public static ArrayList GetAllTasksForClient(long tmpClientID)
        {
            ArrayList TaskList = new ArrayList();
            System.Object lockThis = new System.Object();
            lock (lockThis)
            {
                TaskList = DBUtil.ReadAllTasksForClient(tmpClientID);
            }
            return TaskList;
        }

        /// <summary>
        /// -------------------------------------------------------------------------------
        /// Returns the taskIDs, names for all Tasks for a particular HCW
        /// -------------------------------------------------------------------------------
        /// </summary>
        /// <param name="tmpHCWID"></param>
        /// <returns></returns>
        public static ArrayList GetAllTasksForHCW(long tmpHCWID)
        {
            ArrayList TaskList = new ArrayList();
            System.Object lockThis = new System.Object();
            lock (lockThis)
            {
                TaskList = DBUtil.ReadAllTasksForHCW(tmpHCWID);
            }
            return TaskList;
        }

        /// <summary>
        /// -------------------------------------------------------------------------------
        /// Sets the name of a task
        /// -------------------------------------------------------------------------------
        /// </summary>
        /// <param name="tmpTaskNm"></param>
        public void SetTaskName(String tmpTaskNm)
        {
            taskName = tmpTaskNm;
        }

        /// <summary>
        /// -------------------------------------------------------------------------------
        /// Sets the description for a task
        /// -------------------------------------------------------------------------------
        /// </summary>
        /// <param name="tmpTaskDesc"></param>
        public void SetTaskDescription(String tmpTaskDesc)
        {
            taskDescription = tmpTaskDesc;
        }

        /// <summary>
        /// -------------------------------------------------------------------------------
        /// Sets the ID for a task
        /// -------------------------------------------------------------------------------
        /// </summary>
        /// <param name="tmpTaskID"></param>
        public void SetTaskID(int tmpTaskID)
        {
            taskID = tmpTaskID;
        }
                     
        /// <summary>
        /// -------------------------------------------------------------------------------
        /// Returns the task description
        /// -------------------------------------------------------------------------------
        /// </summary>
        /// <returns></returns>
        public String GetTaskDescription()
        {
            return taskDescription;
        }

        // -------------------------------------------------------------------------------
        // Private data that holds the ID, Name and Description of each class
        // -------------------------------------------------------------------------------
        int taskID;
        String taskName;
        String taskDescription;
        static Utility DBUtil = new Utility();
    }
}
